package com.lishe.lishe.lishe.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.telephony.TelephonyManager;
import java.util.UUID;

public class ImeiUtil {

	@SuppressLint("MissingPermission")
	public static String getIMEI(Context context) {
		try{
			TelephonyManager telephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
			return telephonyMgr.getDeviceId();
		}catch (Exception e){
			return  "ath";
		}

	}

	public static boolean getIsNull(Object str){
		if(str==null||str.equals("")||str.equals("null")||str=="null"||str==""||str.equals(null)){
			return true;
		}
		return false;
	}

	public static boolean getIsNull1(Object str){
		if(str==null||str.equals(0)||str.equals("0")||str=="0"||str==""||str.equals(0)){
			return false;
		}
		return true;
	}

	// 35是IMEI开头的号
	public static String getUniquePsuedoID() {
		String serial = null;
		String m_szDevIDShort = "35" +
				Build.BOARD.length()%10+ Build.BRAND.length()%10 +
				Build.CPU_ABI.length()%10 + Build.DEVICE.length()%10 +
				Build.DISPLAY.length()%10 + Build.HOST.length()%10 +
				Build.ID.length()%10 + Build.MANUFACTURER.length()%10 +
				Build.MODEL.length()%10 + Build.PRODUCT.length()%10 +
				Build.TAGS.length()%10 + Build.TYPE.length()%10 +
				Build.USER.length()%10 ;
		try {       serial = android.os.Build.class.getField("SERIAL").get(null).toString();       //API>=9 使用serial号
			return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
		} catch (Exception exception) {
			//serial需要一个初始化
			serial = "serial";
			// 随便一个初始化
		}   //使用硬件信息拼凑出来的15位号码
		return new UUID(m_szDevIDShort.hashCode(), serial.hashCode()).toString();
	}

}
